package com.example.cash.craft.service.impl;

import com.example.cash.craft.dao.persist.repository.IRewardPointsLogRepository;
import com.example.cash.craft.pojo.core.CurrentPrincipal;
import com.example.cash.craft.pojo.vo.PageData;
import com.example.cash.craft.pojo.vo.RewardPointsLogVO;
import com.example.cash.craft.service.IRewardPointsLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class RewardPointsLogServiceImpl implements IRewardPointsLogService {

    @Value("${cash-craft.config.default-page-size}")
    private Integer defaultPageSize;
    @Autowired
    private IRewardPointsLogRepository rewardPointsLogRepository;

    @Override
    public int sumByUserId(Long userId) {
        return rewardPointsLogRepository.sumByUserId(userId);
    }

    @Override
    public PageData<RewardPointsLogVO> listByUser(Integer page, CurrentPrincipal currentPrincipal) {
        return rewardPointsLogRepository.listByUserId(currentPrincipal.getId(), page, defaultPageSize);
    }
}
